Release 10.1A: OpenEdge Development:
Java Open Clients


Defining the schema for a ProDataSet parameter

Defining the schema for a Progress 4GL ProDataSet (DATASET or DATASET-HANDLE) parameter is a multi-step process.

Note: This is a condensed description with reference to the Java OpenAPI. For complete information on defining the schema for a ProDataSet parameter, see Chapter 5, " Accessing Progress ProDataSets."

To define the schema for a ProDataSet parameter:

  1. Define a com.progress.open4gl.ProDataGraphMetaData object to specify the schema.
  2. Define the temp-tables for the ProDataGraphMetaData object.
  3. Define the data-relations for the ProDataGraphMetaData object.
  4. If the parameter is for input or input-output, define a ProDataGraph using the ProDataGraphMetaData object to hold the parameter value.
  5. Specify the ProDataGraphMetaData object and any ProDataGraph (for input or input-output) as a ProDataSet parameter to your ParamArray object using the appropriate set parameter method.
Defining a ProDataGraphMetaData object

For each ProDataSet parameter you must define a com.progress.open4gl.ProDataGraphMetaData object. You use this object to specify the schema for the ProDataSet when you set the DATASET or DATASET-HANDLE parameter in the ParamArray object. You can create an instance of this object using the following constructor:

Syntax
public ProDataGraphMetaData (string proDataSetName) 

proDataSetName

Specifies the ProDataSet name in the 4GL.

Defining the temp-tables for the ProDataGraphMetaData object

You must define the meta data for each temp-table defined by the ProDataGraphMetaData. For more information, see the "Defining the schema for temp-tables in a ProDataSet" section. You can then add the temp-table meta data (ProDataObjectMetaData) to the ProDataGraphMetaData object using the following ProDataGraphMetaData method:

Syntax
public void addTable (ProDataObjectMetaData doMetaData) 

doMetaData

Specifies the meta data for a temp-table.

Defining the data-relations for the ProDataGraphMetaData object

You must define any data-relations that are defined for the 4GL ProDataSet using com.progress.open4gl.ProDataRelationMetaData objects. You can create a ProDataRelationMetaData object for each data-relation between a parent and child temp-table using the following constructor:

Syntax
public ProDataRelationMetaData(String dataRelationName, int parentIx,  
                               int childIx, int numPairs, string pairsList) 

dataRelationName

Specifies the name of the ProDataRelationMetaData object.

parentIx

Specifies a 0-based index to a parent temp-table (ProDataObject collection) that corresponds to an index into the array of table names returned by the ProDataGraphMetaData getTableNames() method.

childIx

Specifies a 0-based index to a child temp-table (ProDataObject collection) that corresponds to an index into the array of table names returned by the ProDataGraphMetaData getTableNames() method.

numPairs

Specifies the number of column property pairs (key field pairs) that represent this relationship. This allows multiple fields to represent a key relationship between the parent and child temp-table.

pairsList

Specifies a String containing a comma-separated list of field names. The list consists of numPairs field pairs, where the parent temp-table field name for each pair is followed by its matching child temp-table field name. The data types of the named parent and child temp-table field pairs must be comparable.

Note: For the equivalent ProDataRelationMetaData() constructor in the .NET OpenAPI, the order of parent and child field names in the pairsList parameter is reversed. For more information, see OpenEdge Development: .NET Open Clients .

You can add each data-relation definition to the ProDataGraphMetaData object using the following method:

Syntax
public void addDataRelation(ProDataRelationMetaData drMetaData) 

drMetaData

Specifies a data-relation to include in the ProDataGraphMetaData object.

Define a ProDataGraph for any input parameter

If the parameter is for input or input-output, define the com.progress.open4gl.ProDataGraph to hold the value using the following constructor:

Syntax
ProDataGraph(ProDataGraphMetaData dgmd) 

dgmd

Specifies the ProDataGraphMetaData that you have defined for the parameter.

Specifying the ProDataGraphMetaData object for a ProDataSet parameter

Specify the ProDataGraphMetaData object together with any input ProDataGraph by passing them as parameters of the addDataset() or addDatasetHandle() method that you use to add the ProDataSet parameter to the ParamArray object. For more information, see the "DATASET or DATASET-HANDLE" section.

This is an example that adds a temp-table parameter defined with no indexes:

Sample OpenAPI fragment setting a ProDataSet parameter
// Create the ParamArray 
ParamArray parms = new ParamArray(1); 
// Create the ProDataGraphMetaData 
ProDataGraphMetaData dgMetaData = new ProDataGraphMetaData("dsCustOrd"); 
// Create the ProDataObjectMetaData for the Customer table 
ProDataObjectMetaData doCustMD = new ProDataObjectMetaData 
                                 ("ttCust", 3, false, 0, null, null, null); 
doCustMD.setFieldMetaData 
            (1, "CustNum",  0, Parameter.PRO_INTEGER, 0, 0); 
doCustMD.setFieldMetaData 
            (2, "Name",     0, Parameter.PRO_CHARACTER, 1, 0); 
doCustMD.setFieldMetaData 
            (3, "SalesRep", 0, Parameter.PRO_CHARACTER, 2, 0); 
// Create the ProDataObjectMetaData for the Order table 
ProDataObjectMetaData doOrderMD = new ProDataObjectMetaData("OrderDetails", 
6, false, 0, null, null, null); 
doOrderMD.setFieldMetaData 
            (1, "OrderNum", 0, Parameter.PRO_INTEGER, 0, 0); 
doOrderMD.setFieldMetaData 
            (2, "SalesRep", 0, Parameter.PRO_CHARACTER, 1, 0); 
doOrderMD.setFieldMetaData 
            (3, "OrderDate", 0, Parameter.PRO_DATE, 2, 0); 
doOrderMD.setFieldMetaData 
            (4, "ShipDate", 0, Parameter.PRO_DATE, 3, 0); 
doOrderMD.setFieldMetaData 
            (5, "TotalDollars", 0, Parameter.PRO_DECIMAL, 4, 0); 
doOrderMD.setFieldMetaData 
            (6, "OrderStatus", 0, Parameter.PRO_CHARACTER, 5, 0); 
// Add the tables to the ProDataGraph meta data 
dgMetaData.addTable(doCustMD); 
dgMetaData.addTable(doOrderMD); 
// Create and add the relations to the DataSet meta data 
ProDataRelationMetaData relation = new ProDataRelationMetaData 
                                   ("custNum", 0, 1, 1, "CustNum,CustNum"); 
dgMetaData.addDataRelation(relation); 
parms.addDataset(0, null, ParamArrayMode.OUTPUT, dgMetaData); 

For more information on the objects and methods for defining the schema of a ProDataSet parameter and on working with the ProDataGraph used to map a ProDataSet parameter, see Chapter 5, " Accessing Progress ProDataSets."


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095